/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package SessionBeans;

import Classes.Component;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Tomas
 */
@Stateless
public class ComponentFacade implements ComponentFacadeLocal {
    @PersistenceContext
    private EntityManager em;

    public void create(Component component) {
        em.persist(component);
    }

    public void edit(Component component) {
        em.merge(component);
    }

    public void remove(Component component) {
        em.remove(em.merge(component));
    }

    public Component find(Object id) {
        return em.find(Classes.Component.class, id);
    }

    public List<Component> findAll() {
        return em.createQuery("select object(o) from Component as o").getResultList();
    }

}
